import React, { Component } from 'react'
import PropTypes from 'prop-types'

import Item from '../Item'
import './index.css'

export default class List extends Component {
  static propTypes = {
    todos: PropTypes.array.isRequired,
    updateTodosStatus: PropTypes.func.isRequired,
    delTodosItem: PropTypes.func.isRequired
  }

  render() {
    const { todos, updateTodosStatus, delTodosItem } = this.props
    return (
      <ul>
        {todos.map((item) => {
          {
            /* 繁琐写法 */
            /*return <Item todosItem={item} key={item.id} />*/
          }
          return (
            <Item
              key={item.id}
              {...item}
              updateTodosStatus={updateTodosStatus}
              delTodosItem={delTodosItem}
            />
          )
        })}
      </ul>
    )
  }
}
